package com.mediacloud.app.newsmodule.activity

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mediacloud.app.assembly.util.load
import com.mediacloud.app.model.news.ArticleItem
import com.mediacloud.app.newsmodule.R
import com.mediacloud.app.newsmodule.model.MediaListBean

class MediaListAdapter(@LayoutRes var layoutResId: Int) : BaseQuickAdapter<MediaListBean, BaseViewHolder>(layoutResId) {
    override fun convert(helper: BaseViewHolder, item: MediaListBean?) {
        val tvOrder = helper.getView<TextView>(R.id.tvOrder)
        if (helper.adapterPosition == 0){
            tvOrder.setTextColor(Color.parseColor("#F53300"))
        }else if (helper.adapterPosition == 1){
            tvOrder.setTextColor(Color.parseColor("#FFA009"))
        }else if(helper.adapterPosition == 2){
            tvOrder.setTextColor(Color.parseColor("#EFAE89"))
        }else tvOrder.setTextColor(Color.parseColor("#999999"))
//        val view = helper.getView<ImageView>(R.id.ivlistLogo)
//        view.load(item?.url)
        helper.setText(R.id.tvListTitle,item?.title)
        tvOrder.text = "${helper.adapterPosition + 1}"
        item?.sumCount?.let {
            helper.setText(R.id.tvCount,"${item?.sumCount}")
        }
        item?.hitCount?.let {
            helper.setText(R.id.tvCount,"${item?.hitCount}")
        }

    }

}
